var admin_main_apis = {
	changepassword: "http://apibbs.shengyi8888.com/admin/changepassword",
	verifycode: "http://apibbs.shengyi8888.com/bmob/requestSmsCode/",
	adminupdata: "http://apibbs.shengyi8888.com/admin/update"
};
(function() {
	// 修改密码
	App.set("$Event.admin.main.changepassword", function() {
		var data = App.get("$Cache.admin.main.password");
		coAjax.put(admin_main_apis.changepassword, data || {}, function(result) {
			alert("success", "密码修改成功");
		}, function(err, errMsg) {
			alert("warn", errMsg);
		});
	});
	// 获取修改密码验证码
	App.set("$Event.admin.main.get_password_verifycode", function() {
		coAjax.get(admin_main_apis.verifycode + "BBS密码修改", {
			mobilePhoneNumber: App.get("admin.mobile")
		}, function() {
			alert("success", "验证码获取成功");
			var _i = 180;
			var _t = setInterval(function() {
				_i == 0 ? clearInterval(_t) : false;
				App.set("$Cache.admin.main.password_verifycodelimit", _i);
				_i--;
			}, 1000);
		}, function(err, errMsg) {
			alert("warn", errMsg);
			console.log(errMsg);
		})
	});
	// 修改管理员信息
	App.set("$Event.admin.main.changeadmininfo", function() {
		var data = App.get("admin");
		coAjax.put(admin_main_apis.adminupdata, data, function(result) {
			alert("success", "管理员信息已更新");
			// console.log(result);
			App.set("admin", result);
		}, function(err, errMsg) {
			alert("warn", errMsg);
		});
	});
	// 获取修改信息验证码
	App.set("$Event.admin.main.get_info_verifycode", function() {
		coAjax.get(admin_main_apis.verifycode + "BBS修改信息验证", App.get("admin"), function() {
			alert("success", "验证码获取成功");
			var _i = 180;
			var _t = setInterval(function() {
				_i == 0 ? clearInterval(_t) : false;
				App.set("$Cache.admin.main.info_verifycodelimit", _i);
				_i--;
			}, 1000);
		}, function(err, errMsg) {
			alert("warn", errMsg);
		});
	});
}());